﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebSite.cn
{
    public partial class browesProduct : System.Web.UI.UserControl
    {

        string _clientIP;

        public string ClientIP
        {
            get { return _clientIP; }
            set { _clientIP = value; }
        }

        string _browesProductHTML = string.Empty;
        public string BrowesProductHTML
        {
            get
            {
                return _browesProductHTML;
            }
        }
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Bind();    
            }
        }

        private void Bind()
        {
            DataTable table = new DataTable();

            int num2 = 6;// Convert.ToInt32(info.info1("", "shopnum2"));

            table = SQLAccess.GreatDs("select top " + num2 + " S.proid,S.proname,S.proprice1,S.proprice3,S.propic2,S.typeid from DB_Shoppro S JOIN tblLastbrowesProduct P ON S.proid = P.proid WHERE P.IP = '" + ClientIP + "' order by P.browesTime DESC").Tables[0];
            if (table.Rows.Count > 0)
            {
                int num6 = 0;
                this._browesProductHTML = "<table>";
                foreach (DataRow row2 in table.Rows)
                {
                    this._browesProductHTML = this._browesProductHTML + "<tr>";
                    this._browesProductHTML = this._browesProductHTML + "<td valign='top'>";
                    string str4 = this._browesProductHTML;
                    this._browesProductHTML = str4 + "<div class='product_hot_img'><p><a href='products_details.aspx?pid=" + row2["proid"].ToString() + "&sid=1'><img src=../uploadfile/product/" + row2["propic2"].ToString() + " width='35px' /></a></p></div>";
                    this._browesProductHTML = this._browesProductHTML + "<div class='product_hot_text'` ><ul>";
                    string str5 = this._browesProductHTML;
                    string strLeftTrim = "";
                    strLeftTrim = row2["proname"].ToString().Trim().Length > 8 ? fun.Left(row2["proname"].ToString(), 8) + "..." : row2["proname"].ToString();
                    this._browesProductHTML = str5 + "<li><a href='products_details.aspx?pid=" + row2["proid"].ToString() + "&sid=1' title='" + row2["proname"].ToString() + "'>" + strLeftTrim + "</a></li>";
                  //  this._browesProductHTML = this._browesProductHTML + "<li class='text03'>" + string.Format("{0:f}", row2["proprice3"]) + "</li>";
                    this._browesProductHTML = this._browesProductHTML + "<li class='text_red'>" + string.Format("{0:f}", row2["proprice1"]) + "</li>";
                    this._browesProductHTML = this._browesProductHTML + "</ul></div>";
                    this._browesProductHTML = this._browesProductHTML + "</td>";
                    num6++;
                    if (num6 >= num2)
                    {
                        break;
                    }

                    this._browesProductHTML = this._browesProductHTML + "</tr>";

                }
                this._browesProductHTML = this._browesProductHTML + "</table>";
            }
        
        }
    }
}